
#include "./registry.h"
#include "./tasks.h"

namespace fasmio { namespace service { namespace registry {

REGISTER_SERVICE("registry", Registry);

Registry::Registry(const char* name, IServiceAgent *agent, ILogger *logger) :
    ServiceBase(name, agent, logger)
{
}

bool Registry::OnInitialize()
{
    if (!RegisterUpdateSlot<Registry, NodeTask, NodesTask, &Registry::DoHeartBeat>("heart-beat", NodeTask::Allocator))
        return false;
    if (!RegisterUpdateSlot<Registry, NodeTask, NodesTask, &Registry::DoUnregister>("unregister", NodeTask::Allocator))
        return false;
    if (!RegisterQuerySlot<Registry, NodesTask, &Registry::DoGetNodes>("nodes"))
        return false;

    // TODO: do additional initialization for Registry

    return true;
}

void Registry::OnFinalize()
{
    // TODO: Registry::OnFinalize
}

bool Registry::DoHeartBeat(IRequest*, NodeTask*, NodesTask**)
{
    // TODO: Registry::DoHeartBeat
    return true;
}

bool Registry::DoUnregister(IRequest*, NodeTask*, NodesTask**)
{
    // TODO: Registry::DoUnregister
    return true;
}

bool Registry::DoGetNodes(IRequest*, NodesTask**)
{
    // TODO: Registry::DoGetNodes
    return true;
}


}}}  // namespace fasmio::service::registry

